<?php


namespace api\modules\v1\controllers;
use api\controllers\OnAuthController;
use common\models\byxcx\Address;
use common\models\byxcx\Message;
use think\Request;
class CompanyController extends OnAuthController
{
    public $modelClass = '';
    protected $authOptional = ['company','message'];

    //公司地址
    public function actionCompany(){
        $data =Address::find()
            ->select('phone,mail,postcode,address,company')
            ->asarray()
            ->all();
        if ($data) {
            return $data;
        } else {
            return ['code' => 0, 'msg' => "失败", 'data' => []];
        }
    }
    //联系我们
    public function actionMessage()
    {
        $id =\Yii::$app->request->post();
        $data =new Message();
        $data->name = $id['name'];
        $data->phone = $id['phone'];
        $data->wechat = $id['wechat'];
        $data->company = $id['company'];
        $data->type = $id['type'];
        $data->demand = $id['demand'];

        if ($data->save()){
            return '留言成功';
        }

    }
}